/**
 * Copyright (c) 2018, wuyy All rights reserved.
 * wuyy 专有/保密源代码,未经许可禁止任何人通过任何渠道使用、修改源代码.
 * QQ:16349023
 * 项目名称 : com.wy2.eclipse.tool.ui
 * @version V1.0
 */
package com.wy2.eclipse.tool.ui.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import com.wy2.eclipse.tool.ui.wizard.ProjectGenerateWizard;

/**
 * 生成项目处理器
 * @author wuyy<16349023@qq.com>
 * @date 2018年1月30日下午4:53:27
 * 
 */
public class GenerateProjectHandler extends AbstractHandler {

    /** 
     * @param event
     * @return
     * @throws ExecutionException 
     * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
     */
    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
        ISelection selection=HandlerUtil.getCurrentSelection(event);
        
        ProjectGenerateWizard wizard = new ProjectGenerateWizard();
        wizard.init(window.getWorkbench(), selection instanceof IStructuredSelection ? (IStructuredSelection)selection : StructuredSelection.EMPTY);
        WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
        dialog.open();
        return null;
    }

}
